package com.gurun.camera.device.bean;

import android.support.v4.util.ArrayMap;

import com.danale.player.listener.MediaState;
import com.danale.sdk.platform.constant.device.OnlineType;
import com.danale.sdk.platform.constant.device.ProductType;

import java.util.List;
import java.util.Map;

public class MultiDevice extends VideoDevice {

    private Map<Integer, MediaState> mVideoStateMap = new ArrayMap<>();
    private Map<Integer, MediaState> mAudioStateMap = new ArrayMap<>();
    private Map<Integer, MediaState> mTalkStateMap = new ArrayMap<>();
    private Map<Integer, MediaState> mRecordStateMap = new ArrayMap<>();

    MultiDevice(){

    }

    @Override
    public MediaState getVideoState(int chan) {
        return mVideoStateMap.get(chan);
    }

    @Override
    public MediaState getAudioState(int chan) {
        return mAudioStateMap.get(chan);
    }

    @Override
    public MediaState getTalkState(int chan) {
        return mTalkStateMap.get(chan);
    }

    @Override
    public MediaState getRecordState(int chan) {
        return mRecordStateMap.get(chan);
    }

    @Override
    public void setVideoState(int chan, MediaState state) {
        mVideoStateMap.put(chan, state);
    }

    @Override
    public void setAudioState(int chan, MediaState state) {
        mAudioStateMap.put(chan, state);
    }

    @Override
    public void setTalkState(int chan, MediaState state) {
        mTalkStateMap.put(chan, state);
    }

    @Override
    public void setRecordState(int chan, MediaState state) {
        mRecordStateMap.put(chan, state);
    }

    public static class Builder{
        String device_id;
        List<ProductType> deviceType;
        int chan_num;
        int total_chan;
        int aviliable_chan;
        OnlineType onlineType;

        public Builder(){

        }

        public Builder setDevice_id(String device_id) {
            this.device_id = device_id;
            return this;
        }

        public Builder setDeviceType(List<ProductType> deviceType) {
            this.deviceType = deviceType;
            return this;
        }

        public Builder setChanNum(int chan_num) {
            this.chan_num = chan_num;
            return this;
        }

        public Builder setTotal_chan(int total_chan) {
            this.total_chan = total_chan;
            return this;
        }

        public Builder setAviliable_chan(int aviliable_chan) {
            this.aviliable_chan = aviliable_chan;
            return this;
        }

        public Builder setOnlineType(OnlineType onlineType) {
            this.onlineType = onlineType;
            return this;
        }

        public MultiDevice build(){
            MultiDevice multiDevice = new MultiDevice();
            multiDevice.deviceType = deviceType;
            multiDevice.device_id = device_id;
            multiDevice.avilable_chan = aviliable_chan;
            multiDevice.chan_num = chan_num;
            multiDevice.total_chan = total_chan;
            multiDevice.onlineType = onlineType;
            for (Integer i = 1; i <= chan_num; i++){
                multiDevice.mRecordStateMap.put(i, MediaState.IDLE);
                multiDevice.mVideoStateMap.put(i, MediaState.IDLE);
                multiDevice.mAudioStateMap.put(i, MediaState.IDLE);
                multiDevice.mTalkStateMap.put(i, MediaState.IDLE);
            }
            return multiDevice;
        }

    }
}
